Welcome to 'Introduction to the FaaS Model.' After watching this video, you will be able to: Describe what FaaS is,
explain the benefits of a FaaS model, and describe the principles
and best practices of FaaS. Function-as-a-Service or FaaS, is a type of
cloud-computing service that allows you to execute code
in response to events without the complex infrastructure
typically associated with building and launching microservices applications. FaaS includes the following characteristics: It is a subset of serverless computing. It creates applications in the form of
multiple functions where a function is a piece of software written
in any programming language. FaaS can be deployed on hybrid clouds
as well as on-premises environments. It is stateless but can maintain
state using external caches. Functions execute in milliseconds and
process individual requests in parallel, thus making them instantaneously scalable. It is lightweight and uses the
decoupling architecture mechanism. and FaaS is billed on the time taken to run
functions and not on server instance sizes. With FaaS, you can divide the server into
functions that can be scaled automatically and independently so you don’t
have to manage infrastructure. This allows you to focus on the app code
that reduces time-to-market. One of the biggest benefits
of the FaaS model is the cost. You pay only when an action occurs. When the action is complete,
everything stops—no code runs, no server idles, and no costs are incurred. Since the functions are stateless,
small and independent pieces of code, they can be scaled automatically,
independently, and instantaneously, as required. And if demand drops, they
automatically scale back down. And FaaS offers inherent high availability
because it is spread across regions and availability zones and can be
deployed without incremental costs. A serverless stack comprises of
three main components, namely: Functions-as-a-service or FaaS,
Backend-as-a-service or BaaS, and an API Gateway. Let's look at how the components
in a serverless stack work. Event requests are received from
different channels like an HTTP request, webhooks from repositories such as Github and Docker Hub,
and scheduled jobs. These requests go through the API Gateway which identifies and forwards them
to the respective functions. The functions then process these
requests, and they are further directed (if necessary) toward the backend
services (such as file and object storage, block storage, notification services, and so
on) for further processing and/or storage. The output or response is then sent back to the client through the FaaS
component and the API Gateway. For a real-world example, consider the scenario where you need to
upload a profile picture to a website. The website might also require a thumbnail of
that image for displaying on certain web pages. This is a common situation in which
function-as-a-service is used. A user selects a profile photo. The image is uploaded to an object storage bucket. This event triggers an IBM Cloud function that processes the profile photo
and creates a thumbnail image. The function then stores the thumbnail
image in object storage so that if needed, the website can access the thumbnail. FaaS functions should be designed to do a
single piece of work in response to an event. So, make your code scope limited,
efficient, and lightweight so that functions load and execute quickly. The value of FaaS is in
the isolation of functions. Too many functions will increase your costs and remove the value of the
isolation of your functions. Using too many third-party libraries can
slow down the initialization of a function and make them harder to scale. Some of the common managed FaaS providers are: AWS Lambda from Amazon,
Google Cloud functions, Azure functions from Microsoft,
Cloud functions by IBM, OpenShift Cloud Functions from Red Hat,
and a few others like Netlify, Oracle, and Twilio. Now there are many self-managed FaaS choices available too if you don’t want to depend
on third-party managed platforms. These include: Fission, which is a framework for
serverless functions on Kubernetes, Fn Project, a container-native
serverless platform, Knative, a Kubernetes-based platform to
build, deploy, and manage serverless workload, and OpenFaaS, which allows you to turn any
Linux or Windows process into a function. In this video, you learned that: FaaS is a type of cloud-computing service that allows you to execute code in response to
events without a complex infrastructure, FaaS is a subset of serverless computing that creates applications in the
form of multiple functions, FaaS can be deployed on hybrid clouds
as well as on-premises environments, FaaS is billed on the time taken to run
functions and not on server instance sizes, a serverless stack is comprised
of FaaS, BaaS, and an API Gateway, and there are several different managed and
self-managed FaaS platforms to choose from.